﻿Imports Equipment.DataAccess
Imports Equipment.Model

Namespace Equipment
    <RequiresAuthentication()> _
    Public Class HistoryController
        Inherits System.Web.Mvc.Controller

        ' POST: /History
        <HttpPost()> _
        Function Index(ByVal entityType As String, ByVal pageNo As Integer) As ActionResult
            Dim paresedEntityType As EntityType = [Enum].Parse(GetType(EntityType), entityType)
            ViewData("History") = ModificationHistory.RetrievePage(paresedEntityType, pageNo)
            Return View()
        End Function

        ' POST: /History/EntityHistory
        <HttpPost()> _
        Function EntityHistory(ByVal entityType As String, ByVal entityID As Integer, ByVal pageNo As Integer) As ActionResult
            Dim paresedEntityType As EntityType = [Enum].Parse(GetType(EntityType), entityType)
            ViewData("History") = ModificationHistory.RetrievePage(paresedEntityType, entityID, pageNo)
            Return View("Index")
        End Function

        ' POST: /History/Detail
        <HttpPost()> _
        Function Detail(ByVal id As Integer) As ActionResult
            Dim historyToShow As ModificationHistory = ModificationHistory.GetByPrimaryKey(id)
            ViewData("History") = historyToShow
            Return PartialView("~/Views/History/Controls/HistoryDetail.ascx")
        End Function

        ' POST: /History/WorkOrderHistory
        <HttpPost()> _
        Function WorkOrderHistory(ByVal entityID As Integer) As ActionResult
            ViewData("History") = ModificationHistory.RetrieveAllByEntityTypeAndID(EntityType.WorkOrder, entityID)
            Return View("Index")
        End Function

    End Class
End Namespace